<template>
	<el-form-item :label="$t('designer.setting.minLength')">
		<el-input type="number" @input="inputNumberHandler" class="hide-spin-button"
				  min="0" v-model="minLength" style="width: 100%"></el-input>
	</el-form-item>
</template>

<script>
import propertyMixin from "@/components/designer/form-designer/setting-panel/property-editor/propertyMixin"

export default {
	name: "minLength-editor",
	mixins: [propertyMixin],
	props: {
		designer: Object,
		selectedWidget: Object,
		optionModel: Object,
	},
	computed: {
		minLength: {
			get() {
				return this.optionModel['minLength']
			},
			set(newValue) {
				if (!newValue || isNaN(newValue)) {
					this.thisOptionModel.minLength = null
				} else {
					this.thisOptionModel.minLength = Number(newValue)
				}
			}
		},
	},
	data() {
		return {
			thisOptionModel: this.optionModel
		}
	},
	watch: {
		'optionModel': {
			handler(val) {
				if (val) {
					this.thisOptionModel = val
				}
			}
		},
	},
}
</script>

<style scoped>

</style>
